package com.bwc.subject.infra.rpc;

import com.bwc.auth.api.UserFeignService;
import com.bwc.auth.entity.AuthUserDTO;
import com.bwc.auth.entity.Result;
import com.bwc.subject.infra.entity.UserInfo;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class UserRpc {

    @Resource
    private UserFeignService userFeignService;


public UserInfo getUserInfo(String userName) {
    AuthUserDTO authUserDTO = new AuthUserDTO();
    authUserDTO.setUserName(userName);
    Result<AuthUserDTO> result = userFeignService.getUserInfo(authUserDTO);
    UserInfo userInfo = new UserInfo();
    if (!result.getSuccess()) {
        return userInfo;
    }
    userInfo.setNickName(result.getData().getNickName());
    userInfo.setUserName(result.getData().getUserName());
    userInfo.setAvatar(result.getData().getAvatar());
    return userInfo;
}
}
